//
//  WZGAplyDetailVC.m
//  ZCJZ
//
//  Created by 潘洪波 on 2020/2/27.
//  Copyright © 2020 jeking. All rights reserved.
//

#import "WZGAplyDetailVC.h"
#import "WZGAplyFillInformationTwoCell.h"
#import "WZGAplyFillInfomationOneCell.h"
#import "JZLPhotoBrowser.h"

@interface WZGAplyDetailVC ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) UITableView *mTableView ;

@end


@implementation WZGAplyDetailVC

- (void)viewDidLoad{
    [super viewDidLoad];
    self.mTableView.delegate = self;
    self.mTableView.dataSource = self;
    self.mTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.mTableView.estimatedRowHeight = 100;
    
    self.view.backgroundColor = UIColorFromRGB(0xf5f5f5);
}

#pragma mark - UITableViewDataSource
#pragma mark -

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 3;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    WeakSelf(self);
    switch (indexPath.section) {
        case 0:
        {
            WZGAplyFillInformationTwoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"twoCell"];
            if (!cell) {
                cell = [[WZGAplyFillInformationTwoCell alloc] initWithFlex:nil reuseIdentifier:@"twoCell"];
            }
            cell.forntImg = self.model.id_card_front;
            cell.backImg = self.model.id_card_back;
            cell.hideActionText = YES;
            cell.imageTaped = ^(NSInteger tag) {
                if (tag == 100) {
                    [JZLPhotoBrowser showPhotoBrowserWithURLArr:@[weakself.model.id_card_front] atIndex:0 onView:nil canTapCancel:YES];
                }else{
                    [JZLPhotoBrowser showPhotoBrowserWithURLArr:@[weakself.model.id_card_back] atIndex:0 onView:nil canTapCancel:YES];
                }
            };
            return cell;
        }
            break;
        case 1:
        {
            WZGAplyFillInfomationOneCell *cell = [tableView dequeueReusableCellWithIdentifier:@"oneCell"];
            if (!cell) {
                cell = [[WZGAplyFillInfomationOneCell alloc] initWithFlex:nil reuseIdentifier:@"oneCell"];
            }
            cell.placeholderImg = [UIImage imageNamed:@"idcard_inhand"];
            cell.cerImg = self.model.id_card_inhand;
            cell.title = @"手持身份证";
            cell.hideActionText = YES;
            cell.imageTaped = ^{
                [JZLPhotoBrowser showPhotoBrowserWithURLArr:@[weakself.model.id_card_inhand] atIndex:0 onView:nil canTapCancel:YES];
            };
            return cell;
        }
            break;
        case 2:
        {
            WZGAplyFillInfomationOneCell *cell = [tableView dequeueReusableCellWithIdentifier:@"oneCell"];
            if (!cell) {
                cell = [[WZGAplyFillInfomationOneCell alloc] initWithFlex:nil reuseIdentifier:@"oneCell"];
            }
            if (self.model.channel == 1) {
                cell.title = @" 毕业证/学生证/在校证明";
                cell.placeholderImg = [UIImage imageNamed:@"idcard_xuesheng"];
            }else if (self.model.channel == 2){
                cell.title = @" 残疾人证照片或残障人士证明";
                cell.placeholderImg = [UIImage imageNamed:@"idcard_canji"];
            }
            cell.cerImg = self.model.other_cert;
            cell.hideActionText = YES;
            cell.imageTaped = ^{
                [JZLPhotoBrowser showPhotoBrowserWithURLArr:@[weakself.model.other_cert] atIndex:0 onView:nil canTapCancel:YES];
            };
            return cell;
        }
            break;

        default:
            return [UITableViewCell new];
            break;
    }
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView *v = [UIView new];
    v.backgroundColor = [UIColor clearColor];
    return v;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 10;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return UITableViewAutomaticDimension;
}

#pragma mark - UITableViewDelegate
#pragma mark -

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
}

- (void)setModel:(WZGAfterAplyStatusModel *)model{
    _model = model;
    [self.mTableView reloadData];
}

- (void)basePopAction{
    [self.navigationController popToRootViewControllerAnimated:YES];
}

@end
